home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_Tix.idb / usr / freeware / lib / tix4.1 / demos / samples / LabEntry.tcl.z / LabEntry.tcl
Encoding:
Text File  |  1999-01-26  |  2.5 KB  |  91 lines

  1. # Tix Demostration Program
  2. #
  3. # This sample program is structured in such a way so that it can be
  4. # executed from the Tix demo program "widget": it must have a
  5. # procedure called "RunSample". It should also have the "if" statment
  6. # at the end of this file so that it can be run as a standalone
  7. # program using tixwish.
  8.  
  9. # This file demonstrates the use of the tixLabelEntry widget -- an entry that
  10. # come with a label at its side, so you don't need to create
  11. # extra frames on your own and do the messy hierarchical packing. This
  12. # example is adapted from the tixControl example, except now you don't
  13. # have arrow buttons to adjust the values for you ...
  14. #
  15.  
  16. proc RunSample {w} {
  17.  
  18.     # Create the tixLabelEntrys on the top of the dialog box
  19.     #
  20.     frame $w.top -border 1 -relief raised
  21.  
  22.     # $w.top.a allows only integer values
  23.     #
  24.     # [Hint] The -options switch sets the options of the subwidgets.
  25.     # [Hint] We set the label.width subwidget option of the Controls to 
  26.     #        be 16 so that their labels appear to be aligned.
  27.     #
  28.     global lent_demo_maker lent_demo_thrust lent_demo_num_engins
  29.     set lent_demo_maker    P&W
  30.     set lent_demo_thrust    20000.0
  31.     set lent_demo_num_engins 2
  32.  
  33.     tixLabelEntry $w.top.a -label "Number of Engines: " \
  34.     -options {
  35.         entry.width 10
  36.         label.width 20
  37.         label.anchor e
  38.         entry.textVariable lent_demo_num_engins
  39.     }
  40.  
  41.     tixLabelEntry $w.top.b -label "Thrust: "\
  42.     -options {
  43.         entry.width 10
  44.         label.width 20
  45.         label.anchor e
  46.         entry.textVariable lent_demo_thrust
  47.     }
  48.  
  49.     tixLabelEntry $w.top.c -label "Engin Maker: " \
  50.     -options {
  51.         entry.width 10
  52.         label.width 20
  53.         label.anchor e
  54.         entry.textVariable lent_demo_maker
  55.     }
  56.  
  57.     pack $w.top.a $w.top.b $w.top.c -side top -anchor w
  58.  
  59.     # Use a ButtonBox to hold the buttons.
  60.     #
  61.     tixButtonBox $w.box -orientation horizontal
  62.     $w.box add ok     -text Ok     -underline 0 -command "labe:okcmd $w" \
  63.     -width 6
  64.     $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
  65.     -width 6
  66.  
  67.     pack $w.box -side bottom -fill x
  68.     pack $w.top -side top -fill both -expand yes
  69. }
  70.  
  71. proc labe:okcmd {w} {
  72.     global lent_demo_maker lent_demo_thrust lent_demo_num_engins
  73.  
  74.     puts "You selected $lent_demo_num_engins engin(s) of thrust $lent_demo_thrust made \
  75. by $lent_demo_maker"
  76.  
  77.     destroy $w
  78. }
  79.  
  80.  
  81. # This "if" statement makes it possible to run this script file inside or
  82. # outside of the main demo program "widget".
  83. #
  84. if {![info exists tix_demo_running]} {
  85.     wm withdraw .
  86.     set w .demo
  87.     toplevel $w
  88.     RunSample $w
  89.     bind $w <Destroy> exit
  90. }
  91.